package com.bio.dao.information.impl;

import org.hibernate.criterion.Restrictions;
import com.bio.dao.impl.HibernateDaoImpl;
import com.bio.dao.impl.HibernateQuery;
import com.bio.dao.information.InformationDAO;
import com.bio.entity.information.Information;
import com.bio.utils.Pager;
import com.bio.utils.Pagination;

public class InformationDAOImpl extends HibernateDaoImpl<Information> implements InformationDAO{

	@Override
	public Pager<Information> findPagerByCompanyId(Pagination pagination,
			Long companyId) {
		if(null == companyId){
			return new HibernateQuery<Information>(this.getSessionFactory(), 
				this.getSession(), Information.class).setPagination(pagination)
					                              .addWhere(Restrictions.isNull("companyId")).query();
		}else{
		    return new HibernateQuery<Information>(this.getSessionFactory(), 
				this.getSession(), Information.class).setPagination(pagination)
				                                  .addWhere(Restrictions.eq("companyId",companyId)).query();
		}
	}

}
